package com.aipolice.service;

import com.aipolice.dao.ConnewsDAO;
import com.aipolice.pojo.Connews;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class ConnewsService {
    @Autowired
    ConnewsDAO connewsDAO;

    public List<Connews> list() {
        return connewsDAO.findAll();
    }

    public void delete(int id){
//        真删除
        connewsDAO.deleteById(id);
//        软删除
//        Connews connews = connewsDAO.findById(id).get();
//        user.setDel(1);
//        connewsDAO.save(user);
    }


    public void add(Connews connews){
        connewsDAO.save(connews);
    }

    public Connews find(int id){
        Optional<Connews> connews = connewsDAO.findById(id);
        return connews.get();
    }


}
